.class public Lcom/qiniu/auth/Client$ClientExecutor;
.super Landroid/os/AsyncTask;
.source "Client.java"

# interfaces
.implements Lcom/qiniu/utils/ICancel;


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/qiniu/auth/Client;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x1
    name = "ClientExecutor"
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "Landroid/os/AsyncTask",
        "<",
        "Ljava/lang/Object;",
        "Ljava/lang/Object;",
        "Ljava/lang/Object;",
        ">;",
        "Lcom/qiniu/utils/ICancel;"
    }
.end annotation


# instance fields
.field mHttpRequest:Lorg/apache/http/client/methods/HttpRequestBase;

.field mRet:Lcom/qiniu/auth/CallRet;

.field final synthetic this$0:Lcom/qiniu/auth/Client;


# direct methods
.method public constructor <init>(Lcom/qiniu/auth/Client;)V
    .registers 2
    .param p1, "this$0"    # Lcom/qiniu/auth/Client;

    .prologue
    .line 74
    iput-object p1, p0, Lcom/qiniu/auth/Client$ClientExecutor;->this$0:Lcom/qiniu/auth/Client;

    invoke-direct {p0}, Landroid/os/AsyncTask;-><init>()V

    return-void
.end method


# virtual methods
.method protected varargs doInBackground([Ljava/lang/Object;)Ljava/lang/Object;
    .registers 9
    .param p1, "objects"    # [Ljava/lang/Object;

    .prologue
    .line 88
    :try_start_0
    iget-object v5, p0, Lcom/qiniu/auth/Client$ClientExecutor;->this$0:Lcom/qiniu/auth/Client;

    iget-object v6, p0, Lcom/qiniu/auth/Client$ClientExecutor;->mHttpRequest:Lorg/apache/http/client/methods/HttpRequestBase;

    invoke-virtual {v5, v6}, Lcom/qiniu/auth/Client;->roundtrip(Lorg/apache/http/client/methods/HttpRequestBase;)Lorg/apache/http/HttpResponse;

    move-result-object v2

    .line 89
    .local v2, "resp":Lorg/apache/http/HttpResponse;
    invoke-interface {v2}, Lorg/apache/http/HttpResponse;->getStatusLine()Lorg/apache/http/StatusLine;

    move-result-object v5

    invoke-interface {v5}, Lorg/apache/http/StatusLine;->getStatusCode()I

    move-result v3

    .line 90
    .local v3, "statusCode":I
    const/16 v5, 0x191

    if-ne v3, v5, :cond_1c

    .line 91
    new-instance v0, Ljava/lang/Exception;

    const-string v5, "unauthorized!"

    invoke-direct {v0, v5}, Ljava/lang/Exception;-><init>(Ljava/lang/String;)V

    .line 108
    .end local v2    # "resp":Lorg/apache/http/HttpResponse;
    .end local v3    # "statusCode":I
    :cond_1b
    :goto_1b
    return-object v0

    .line 93
    .restart local v2    # "resp":Lorg/apache/http/HttpResponse;
    .restart local v3    # "statusCode":I
    :cond_1c
    invoke-interface {v2}, Lorg/apache/http/HttpResponse;->getEntity()Lorg/apache/http/HttpEntity;

    move-result-object v5

    invoke-static {v5}, Lorg/apache/http/util/EntityUtils;->toByteArray(Lorg/apache/http/HttpEntity;)[B

    move-result-object v0

    .line 95
    .local v0, "data":[B
    div-int/lit8 v5, v3, 0x64

    const/4 v6, 0x2

    if-eq v5, v6, :cond_1b

    .line 96
    array-length v5, v0

    if-nez v5, :cond_56

    .line 97
    const-string v5, "X-Log"

    invoke-interface {v2, v5}, Lorg/apache/http/HttpResponse;->getFirstHeader(Ljava/lang/String;)Lorg/apache/http/Header;

    move-result-object v5

    invoke-interface {v5}, Lorg/apache/http/Header;->getValue()Ljava/lang/String;

    move-result-object v4

    .line 98
    .local v4, "xlog":Ljava/lang/String;
    invoke-virtual {v4}, Ljava/lang/String;->length()I

    move-result v5

    if-lez v5, :cond_48

    .line 99
    new-instance v0, Ljava/lang/Exception;

    .end local v0    # "data":[B
    invoke-direct {v0, v4}, Ljava/lang/Exception;-><init>(Ljava/lang/String;)V
    :try_end_41
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_41} :catch_42

    goto :goto_1b

    .line 106
    .end local v2    # "resp":Lorg/apache/http/HttpResponse;
    .end local v3    # "statusCode":I
    .end local v4    # "xlog":Ljava/lang/String;
    :catch_42
    move-exception v1

    .line 107
    .local v1, "e":Ljava/io/IOException;
    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V

    move-object v0, v1

    .line 108
    goto :goto_1b

    .line 101
    .end local v1    # "e":Ljava/io/IOException;
    .restart local v0    # "data":[B
    .restart local v2    # "resp":Lorg/apache/http/HttpResponse;
    .restart local v3    # "statusCode":I
    .restart local v4    # "xlog":Ljava/lang/String;
    :cond_48
    :try_start_48
    new-instance v0, Ljava/lang/Exception;

    .end local v0    # "data":[B
    invoke-interface {v2}, Lorg/apache/http/HttpResponse;->getStatusLine()Lorg/apache/http/StatusLine;

    move-result-object v5

    invoke-interface {v5}, Lorg/apache/http/StatusLine;->getReasonPhrase()Ljava/lang/String;

    move-result-object v5

    invoke-direct {v0, v5}, Ljava/lang/Exception;-><init>(Ljava/lang/String;)V

    goto :goto_1b

    .line 103
    .end local v4    # "xlog":Ljava/lang/String;
    .restart local v0    # "data":[B
    :cond_56
    new-instance v1, Ljava/lang/Exception;

    new-instance v5, Ljava/lang/String;

    invoke-direct {v5, v0}, Ljava/lang/String;-><init>([B)V

    invoke-direct {v1, v5}, Ljava/lang/Exception;-><init>(Ljava/lang/String;)V
    :try_end_60
    .catch Ljava/io/IOException; {:try_start_48 .. :try_end_60} :catch_42

    move-object v0, v1

    goto :goto_1b
.end method

.method protected onPostExecute(Ljava/lang/Object;)V
    .registers 3
    .param p1, "o"    # Ljava/lang/Object;

    .prologue
    .line 119
    instance-of v0, p1, Ljava/lang/Exception;

    if-eqz v0, :cond_c

    .line 120
    iget-object v0, p0, Lcom/qiniu/auth/Client$ClientExecutor;->mRet:Lcom/qiniu/auth/CallRet;

    check-cast p1, Ljava/lang/Exception;

    .end local p1    # "o":Ljava/lang/Object;
    invoke-virtual {v0, p1}, Lcom/qiniu/auth/CallRet;->onFailure(Ljava/lang/Exception;)V

    .line 124
    :goto_b
    return-void

    .line 123
    .restart local p1    # "o":Ljava/lang/Object;
    :cond_c
    iget-object v0, p0, Lcom/qiniu/auth/Client$ClientExecutor;->mRet:Lcom/qiniu/auth/CallRet;

    check-cast p1, [B

    .end local p1    # "o":Ljava/lang/Object;
    check-cast p1, [B

    invoke-virtual {v0, p1}, Lcom/qiniu/auth/CallRet;->onSuccess([B)V

    goto :goto_b
.end method

.method protected varargs onProgressUpdate([Ljava/lang/Object;)V
    .registers 8
    .param p1, "values"    # [Ljava/lang/Object;

    .prologue
    .line 114
    iget-object v1, p0, Lcom/qiniu/auth/Client$ClientExecutor;->mRet:Lcom/qiniu/auth/CallRet;

    const/4 v0, 0x0

    aget-object v0, p1, v0

    check-cast v0, Ljava/lang/Long;

    invoke-virtual {v0}, Ljava/lang/Long;->longValue()J

    move-result-wide v2

    const/4 v0, 0x1

    aget-object v0, p1, v0

    check-cast v0, Ljava/lang/Long;

    invoke-virtual {v0}, Ljava/lang/Long;->longValue()J

    move-result-wide v4

    invoke-virtual {v1, v2, v3, v4, v5}, Lcom/qiniu/auth/CallRet;->onProcess(JJ)V

    .line 115
    return-void
.end method

.method public setup(Lorg/apache/http/client/methods/HttpRequestBase;Lcom/qiniu/auth/CallRet;)V
    .registers 3
    .param p1, "httpRequest"    # Lorg/apache/http/client/methods/HttpRequestBase;
    .param p2, "ret"    # Lcom/qiniu/auth/CallRet;

    .prologue
    .line 78
    iput-object p1, p0, Lcom/qiniu/auth/Client$ClientExecutor;->mHttpRequest:Lorg/apache/http/client/methods/HttpRequestBase;

    .line 79
    iput-object p2, p0, Lcom/qiniu/auth/Client$ClientExecutor;->mRet:Lcom/qiniu/auth/CallRet;

    .line 80
    return-void
.end method

.method public upload(JJ)V
    .registers 8
    .param p1, "current"    # J
    .param p3, "total"    # J

    .prologue
    .line 82
    const/4 v0, 0x2

    new-array v0, v0, [Ljava/lang/Object;

    const/4 v1, 0x0

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v2

    aput-object v2, v0, v1

    const/4 v1, 0x1

    invoke-static {p3, p4}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v2

    aput-object v2, v0, v1

    invoke-virtual {p0, v0}, Lcom/qiniu/auth/Client$ClientExecutor;->publishProgress([Ljava/lang/Object;)V

    .line 83
    return-void
.end method
